using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using RideMe.Core.Properties;

namespace RideMe.Core
{
    public class SelectedFileChangedEventArgs : EventArgs 
    {
        private const string FileCategory = "File Information";

        public SelectedFileChangedEventArgs()
        {
        }

        public SelectedFileChangedEventArgs(string path, string size, DateTime lastWriteTime, DateTime lastAccessed, DateTime created, string fileName)
        {
            this._path = path;
            this._size = size;
            this._lastWriteTime = lastWriteTime;
            this._lastAccessed = lastAccessed;
            this._created = created;
            this._fileName = fileName;
        }

        private bool _renameFile = true;

        [Browsable(false)]
        public bool RenameFile
        {
            get { return _renameFile; }
            set { _renameFile = value; }
        }
	

        private string _path;

        [CategoryAttribute(FileCategory)]
        [ReadOnlyAttribute(true)]
        public string Path
        {
            get { return _path; }
            set { _path = value; }
        }

        private string _size;

        [CategoryAttribute(FileCategory)]
        public string Size
        {
            get { return _size + Resources.Bytes; }
        }

        private DateTime _lastWriteTime;

        [CategoryAttribute(FileCategory)]
        public DateTime LastWriteTime
        {
            get { return _lastWriteTime; }
        }

        private DateTime _lastAccessed;

        [CategoryAttribute(FileCategory)]
        public DateTime LastAccessed
        {
            get { return _lastAccessed; }
        }

        private DateTime _created;

        [CategoryAttribute(FileCategory)]
        public DateTime Created
        {
            get { return _created; }
        }

        private string _fileName;

        [CategoryAttribute(FileCategory)]
        public string FileName
        {
            get { return _fileName; }
            set 
            {
                if (_fileName != value)
                {
                    _fileName = value;

                    // Only do this if so instructed.
                    if (_renameFile)
                    {
                        ProjectService.RenameFile(_path, _fileName,
                            System.IO.Path.Combine(System.IO.Path.GetDirectoryName(_path), _fileName));
                    }

                    _renameFile = true;
                }
            }
        }
	
    }
}
